package com.rayboo.repository;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import com.rayboo.model.ClubCar;

/**
 * 
 * ClubCarRepository
 * 
 * @author ray
 * @date 2016年9月8日 下午8:11:24
 *
 */
public interface ClubCarRepository extends CrudRepository<ClubCar, Integer> {

	/**
	 * 根据条件分页查询
	 * 
	 * @param query
	 * @param pageable
	 * @return
	 */
	@Query("SELECT c from ClubCar c where c.alphabet like %:query% or c.brand like %:query% or c.sname like %:query% order by c.alphabet")
	List<ClubCar> find(@Param("query") String query, Pageable pageable);

	/**
	 * 根据条件查询数量
	 * 
	 * @param query
	 * @return
	 */
	@Query("SELECT count(c) from ClubCar c where c.alphabet like %:query% or c.brand like %:query% or c.sname like %:query% ")
	long count(@Param("query") String query);

}
